<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
      
      <el-form-item label="任务名称" prop="taskName">
        <el-input
          v-model="queryParams.taskName"
          placeholder="请输入"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
     
      <el-form-item label="开始时间" prop="processStartTime">
        <el-date-picker clearable
          v-model="queryParams.processStartTime"
          type="date"
          value-format="YYYY-MM-DD"
          placeholder="请选择">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="结束时间" prop="processEndTime">
        <el-date-picker clearable
          v-model="queryParams.processEndTime"
          type="date"
          value-format="YYYY-MM-DD"
          placeholder="请选择">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="orderList">
      <el-table-column label="任务名称" align="center" prop="taskName" />
      <el-table-column label="流程名称" align="center" prop="processName" />
      <el-table-column label="开始时间" align="center" prop="processStartTime" width="180">
        <template #default="scope">
          <span>{{ parseTime(scope.row.processStartTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="结束时间" align="center" prop="processEndTime" width="180">
        <template #default="scope">
          <span>{{ parseTime(scope.row.processEndTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="发起人" align="center" prop="applyUserName" />
      <el-table-column label="下个处理人" align="center"  />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template #default="scope">
          <el-button
            type="text"
            @click="handleLook(scope.row)"
          >查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />

    <div>
      
      <LookDialog v-model="lookVisible" :workOrderForm="currentRow"></LookDialog>
    </div>

  </div>
</template>

<script setup name="Order">
import { completedListOrder, getOrder, delOrder, addOrder, updateOrder } from "@/api/platform/order";


import LookDialog from '@/views/workOrder/completed/dialog/LookDialog.vue'

const { proxy } = getCurrentInstance();

const orderList = ref([]);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);

const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    taskName: null,
    startTime: null,
    endTime: null,
    status: 3
  },
  rules: {
  }
});

const { queryParams, form, rules } = toRefs(data);

/** 查询异动计划补录列表 */
function getList() {
  loading.value = true;
  completedListOrder(queryParams.value).then(response => {
    orderList.value = response.rows;
    total.value = response.total;
    loading.value = false;
  });
}


/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  handleQuery();
}

const lookVisible = ref(false)
const currentRow = ref(null)

/** 修改按钮操作 */
function handleLook(row) {
  lookVisible.value = true;
  currentRow.value = row;
}



getList();
</script>
